//
//  Toast.m
//  OCBase
//
//  Created by 侯伟 on 2019/4/16.
//  Copyright © 2019年 侯伟. All rights reserved.
//

#import "Toast.h"
#import <MBProgressHUD/MBProgressHUD.h>

@implementation Toast

#pragma mark --MBProgressHUD

+ (void)toast:(NSString*)message{
    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    [Toast toast:message inView:window];
}
    
+ (void)toast:(NSString*)message inView:(UIView*)view{
    MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.offset = CGPointMake(0, -100);
    hud.mode = MBProgressHUDModeText;
    hud.removeFromSuperViewOnHide = YES;
    hud.label.text = message;
    hud.label.textAlignment = NSTextAlignmentLeft;
    hud.label.lineBreakMode = NSLineBreakByCharWrapping;
    hud.label.numberOfLines = 0;
    hud.bezelView.color = COLOR_WHITE;
    [hud hideAnimated:YES afterDelay:1.5f];
}


+ (void)spin:(NSString*)message{
    
    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    [Toast spin:message inView:window];
}
    
+ (void)spin:(NSString *)message inView:(UIView *)view{
    
    [self hidden:view];
    
    MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.offset = CGPointMake(0, -100);
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = UIColor.clearColor;
    hud.mode = MBProgressHUDModeIndeterminate;
    hud.removeFromSuperViewOnHide = YES;
    hud.label.textColor = COLOR_GRAY_BASE;
    hud.label.font = FONT(13);
    hud.label.text = message;
}

+ (void)hidden{
    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    [Toast hidden:window];
}
    
+ (void)hidden:(UIView*)view{
    [MBProgressHUD hideHUDForView:view animated:YES];
}


#pragma mark --SVProgressHUD
//
///// 成功提示
///// @param message 消息
//+ (void)toastSuccess:(NSString * _Nullable)message{
//    
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
//    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
//    [SVProgressHUD showSuccessWithStatus:message];
//    [SVProgressHUD dismissWithDelay:2.0f];
//}
//
///// 失败提示
///// @param message 消息
//+ (void)toastError:(NSString * _Nullable)message{
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
//    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
//    [SVProgressHUD showErrorWithStatus:message];
//    [SVProgressHUD dismissWithDelay:2.0f];
//}
//
///// 提示信息
///// @param notice 消息
//+ (void)toastNotice:(NSString * _Nullable)notice{
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
//    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
//    [SVProgressHUD showInfoWithStatus:notice];
//    [SVProgressHUD dismissWithDelay:2.0f];
//}
//
///// 自定义图片提示
///// @param image 图片
///// @param message 消息
//+ (void)toast:(nonnull UIImage*)image message:(nullable NSString*)message{
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
//    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
//    [SVProgressHUD showImage:image status:message];
//    [SVProgressHUD dismissWithDelay:2.0f];
//}

@end
